package com.ltmt.es.utils.castor;

import java.util.ArrayList;
import java.util.List;

import com.ltmt.es.persistence.entity.HistoricCombination;
import com.ltmt.es.pojo.PrimitivaCombination;

public class PrimitivaCastor {
	
	public static Float[] toStats (Integer[] hitAccumulator, int hTotal){
		
		Float[] hitStats = new Float[5];
		
		for (int i=0;i<hitAccumulator.length;i++){
			hitStats[i] = (( ((float) (hitAccumulator[i])) *100) /hTotal);
		}
		
		return hitStats;
	}
	
	public static HistoricCombination toHistoricCombination (String[] element){
		
		String combination = element[2];
		for (int i=3;i<=7;i++){
			combination = combination+"-"+element[i];
		}
		
		HistoricCombination hComb = new HistoricCombination(element[0], element[1], combination, Integer.parseInt(element[8]));
		
		return hComb;
		
	}

	public static List<PrimitivaCombination> toPrimitivaCombinationList(
			List<HistoricCombination> listHComb) {
		
		PrimitivaCombination pHComb;
		List<PrimitivaCombination> listPHComb = new ArrayList<PrimitivaCombination>();
		
		for (HistoricCombination hComb : listHComb){
			pHComb = new PrimitivaCombination(hComb);
			listPHComb.add(pHComb);
		}
		
		
		return listPHComb;
	}

}
